#ifndef _MOTOR_H_
#define _MOTOR_H_

#include "main.h"
#include "bsp_PWM.h"
#include "PID.h"

#define PI 3.1415926f
#define GearRation 1.f
#define Accuracy 800.f
#define HalfAccuracy 400.f
#define WheelDiameter 0.065f
typedef struct
{
	float accuracy;
	float tyre_diameter;
	float gear_ration;
	uint8_t ID;
	TIM_HandleTypeDef encoder_tim;
}MOTOR_PARAMETER_T;

typedef struct
{
	float target_speed;
	
}MOTOR_COMMAND_T;

typedef struct
{
	float actual_speed;
	float wheel_circumference;
	float encoder_cnt;
	float last_encoder_cnt;
	float encoder_speed;
}MOTOR_STATUS_T;

typedef struct
{
	MOTOR_PARAMETER_T parameter;
	MOTOR_COMMAND_T command;
	MOTOR_STATUS_T status;
	PID_TypeDef		vpid;
	
}MOTOR_T;

void Motor_Init(MOTOR_T *motor,uint8_t ID,float gear_ration,float accuracy,float wheel_diameter,TIM_HandleTypeDef *htim);
 void Motor_Status_Update(MOTOR_T *motor);

#endif